package day06;

import sun.nio.cs.ext.MS950_HKSCS_XP;

//方法的演示
public class MethodDemo {
    public static void main(String[] args) {
        say();
        sayHi("HX");
        sayHello("NB",6);
        System.out.println("继续执行");
        double a=getNum();
        System.out.println(a);

        int d=sum(10,20);
        System.out.println(d);

        int[] arr=testArray(10,100);
        System.out.println("数组的长度为"+arr.length);

        int[] arr1=testArray(10,30);
        System.out.println("数组的第一个元素为"+arr1[0]);

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr1[i]);
        }

    }
    public static int[] testArray(int len,int max){
        int[] arr=new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i]=(int)(Math.random()*(max+1));
        }
        return arr;
    }



    public static int sum(int a,int b){
        int sum=a+b;
        return sum;
    }



    public static double getNum(){
        return 1.36;
    }

    public static void sayHello(String name,int age){
        if (age>50){
            return;
        }
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了");
    }

    public static void sayHi(String name){
        System.out.println("大家好，我叫"+name+"，今年29岁了");
    }
    // 无参无返回值
    public static void say(){
        System.out.println("大家好");
    }


}
